﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OOLib
{
   /// <summary>
   /// Describes the object's position in a text.
   /// </summary>
   /// <remarks>
   /// It represents a text range. The beginning and end of the range may be identical.
   /// </remarks>
   public class TextRange : ComObjectWrapper
   {
      #region Constructors

      /// <summary>
      /// Constructor
      /// </summary>
      /// <remarks>
      /// After using this constructor, the ComObj must be set manually!
      /// </remarks>
      public TextRange() :
         base()
      { }

      /// <summary>
      /// Constructor
      /// </summary>
      /// <param name="comObject">COM object</param>
      public TextRange(object comObject) :
         base(comObject)
      { }

      #endregion

      #region XTextRange
      
      /// <summary>
      /// Gets the text interface in which the text position is contained.
      /// </summary>
      /// <returns>Returns the text interface in which the text position is contained.</returns>
      /// <remarks>!!! Not tested !!!</remarks>
      public Text GetText()
      {
         CheckDisposed();
         return GetObjectWrapper<Text>(InvokeMethod("getText"));
      }

      /// <summary>
      /// Gets the text range which contains only the start of this text range.
      /// </summary>
      /// <returns>Returns a text range which contains only the start of this text range.</returns>
      /// <remarks>!!! Not tested !!!</remarks>
      public TextRange GetStart()
      {
         CheckDisposed();
         return GetObjectWrapper<TextRange>(InvokeMethod("getStart"));
      }

      /// <summary>
      /// Gets the a text range which contains only the end of this text range.
      /// </summary>
      /// <returns>Returns a text range which contains only the end of this text range.</returns>
      /// <remarks>!!! Not tested !!!</remarks>
      public TextRange GetEnd()
      {
         CheckDisposed();
         return GetObjectWrapper<TextRange>(InvokeMethod("getEnd"));
      }

      /// <summary>
      /// Gets or sets the string that is included in this text range.
      /// </summary>
      /// <remarks>
      /// When String is set the whole string of characters of this piece of text is replaced.
      /// All styles are removed when applying this method.
      /// </remarks>
      public string String
      {
         get 
         {
            CheckDisposed();
            return (string)InvokeMethod("getString"); 
         }
         set 
         {
            CheckDisposed(); 
            InvokeMethod("setString", value);
         }
      }

      #endregion
   }
}
